{include file="index/header" /}
<link rel="stylesheet" href="__PUBLIC__admin/play/category.css">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/UEditor-admin/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/UEditor-admin/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/UEditor-admin/lang/zh-cn/zh-cn.js"></script>
<body>
	<div class="panel admin-panel margin-top" id="add">
		<div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 增加内容</strong></div>
		<div class="body-content">
			<form method="post" class="form-x" action="">    
				<div class="form-group">
					<div class="label">
						<label>名称：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="{$course_data.course_name}" name="course_name" data-validate="required:请输入标题" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>分类：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<input name="type" value="1" type="radio" {if $course_data.type eq 1 || !$course_data}  checked="checked" {/if} class="radio_status">视频
							<input name="type" value="2"  type="radio" {if $course_data.type eq 2}  checked="checked" {/if} class="radio_status">挑战
							<input name="type" value="3"  type="radio" {if $course_data.type eq 3}  checked="checked" {/if} class="radio_status">练习
							<input name="type" value="4"  type="radio" {if $course_data.type eq 4}  checked="checked" {/if} class="radio_status">文档
						</div>
					</div>
				</div>
				<!-- <div class="form-group">
					<div class="label">
						<label>是否免费：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if $course_data.is_free eq 1} active {/if}">
								<span class="icon icon-check"></span>
								<input name="is_free" value="1" type="radio" {if $course_data.is_free eq 1}  checked="checked" {/if}>是
							</label>
							<label class="button {if $course_data.is_free eq 0} active {/if}">
								<span class="icon icon-times"></span>
								<input name="is_free" value="0"  type="radio" {if $course_data.is_free eq 0}  checked="checked" {/if}>否
							</label>
						</div>
					</div>
				</div> -->
				<div class="form-group">
					<div class="label">
						<label>当前链接：</label>
					</div>
					<div class="field">
						<input type="text" id="txtcopy" readonly="" value="{$course_data.course_id|uris=###}/learnings/{$course_data.course_id}.html" class="input w50"><a onclick="copyUrl2()" style="margin-left: 20px;cursor: pointer;border: 1px solid #ccc;padding: 5px;background: #ddd;">复制</a>
					</div>
				</div>
				<div class="form-group vid" {if $course_data.type neq 1 && $course_data}style="display:none;"{/if}>
					<div class="label">
						<label>视频：</label>
					</div>
					<div class="field">
						<div class="upload-btn" id="upload-btn">
							<img src="__PUBLIC__images/upload.png"  style="max-height: 101px;" alt="" title="点击上传">
						</div>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group vid" {if $course_data.type neq 1 && $course_data}style="display:none;"{/if}>
					<div class="label">
						<label>视频id：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="{$course_data.vid}" name="vid"  />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group document" {if $course_data.type eq 1 || $course_data.type eq 3 || !$course_data}style="display:none;"{/if}>
					<div class="label">
						<label>文档：</label>
					</div>
					<div class="field container">
						<textarea name="document" id="editor" style="width:845px; height:260px;">{$course_data.document}</textarea>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>分类标题：</label>
					</div>
					<div class="field">
						<select name="nav_id" class="input w50"  id="nav" data-validate="required:请选择专业">
							<option value="">请选择专业</option>
							{foreach name='nav_data' item='nav'}
							<option value="{$nav.nav_id}" {if $nav.nav_id eq $course_data.nav_id} selected=""{/if}>{$nav.nav_name}</option>
							{/foreach}
						</select>  
						<select name="type_id" class="input w50" id="type" data-validate="required:请选择阶段">
							<option value="">请选择阶段</option>
							{foreach name='type_data' item='type'}
							<option value="{$type.type_id}" {if $course_data.type_id eq $type.type_id}selected{/if}>{$type.type_name}</option>
							{/foreach}
						</select>
						<select name="s_id" class="input w50" id="s" data-validate="required:请选择章节">
							<option value="">请选择章节</option>
							{foreach name='s_data' item='s'}
							<option value="{$s.s_id}" {if $course_data.s_id eq $s.s_id}selected{/if}>{$s.s_name}</option>
							{/foreach}
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>简介：</label>
					</div>
					<div class="field">
						<textarea name="course_desc" id="editor1" style="width:845px; height:460px;">{$course_data.course_desc}</textarea>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>掌握点：</label>
					</div>
					<div class="field">
						<input type="number" class="input w50" name="points" value="{$course_data.points ?: 1}"  data-validate="required:,number:掌握点必须为数字" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>是否在前台页面展示：</label>
					</div>
					<div class="field">
						<div class="button-group radio">
							<label class="button {if !$course_data || $course_data.is_show eq 1} active {/if}">
								<span class="icon icon-check"></span>
								<input name="is_show" value="1" type="radio" {if !$course_data || $course_data.is_show eq 1}  checked="checked" {/if}>是
							</label>
							<label class="button {if $course_data && $course_data.is_show eq 0} active {/if}">
								<span class="icon icon-times"></span>
								<input name="is_show" value="0"  type="radio" {if $course_data && $course_data.is_show eq 0}  checked="checked" {/if}>否
							</label>
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>排序：</label>
					</div>
					<div class="field">
						<input type="number" class="input w50" name="course_sort" value="{$course_data.course_sort ?: 0}"  data-validate="required:,number:排序必须为数字" />
						<div class="tips"></div>
					</div>
				</div>
				<input type="hidden" name="uploads" value="0">
				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="wrap" hidden="hidden">
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span10 ml17">
				<div class="upbox" style="margin: 80px;">
					<form id="fileupload" method="POST" enctype="multipart/form-data">
						<div class="row fileupload-buttonbar">
							<div class="col-lg-7 mb10">
								<span class="btn btn-primary fileinput-button">
									<i class="glyphicon glyphicon-plus"></i>
									<span>上传视频</span>
									<!--  <input type="file" name="files"> 单选文件 -->
									<!-- 可多选文件 -->
									<input type="file" name="files[]" directory multiple>
								</span>
								<span class="fileupload-process"></span>
								<span> 分类:</span>
								<div id="subCategorys" style="display:inline-block;position:relative;">
									<input type="hidden" id="uploadCategory" value="0" />
									<input type="text" value="默认分类" title="默认分类" id="selectCategoryInput" />
								</div>
							</div>
						</div>
						<div class="updiv mt1">
							<table class="uptable table table-striped table-hover" style="text-align:center;">
								<thead>
									<tr>
										<th style="width:300px; text-align: center;">文件名</th>
										<th style="width:80px; text-align: center;">格式</th>
										<th style="width:80px; text-align: center;">分类</th>
										<th style="width:80px; text-align: center;">大小</th>
										<th style="width:200px;text-align: center;">状态</th>
										<th style="width:125px; text-align: center;">操作</th>
										<th style="display:none"></th>
									</tr>
								</thead>
								<tbody class="files"></tbody>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div class="footer_push"></div>
</div>
</body></html>
<script>
	var editor =  {
		toolbars: [
		[
		'source',
		'bold',
		'italic',
		'underline',
		'subscript',
		'superscript',
		'removeformat',
		'unlink',
		'insertcode',
		'fontfamily',
		'fontsize',
		'justifyleft',
		'justifyright',
		'justifycenter',
		'justifyjustify',
		'simpleupload',
		'insertimage',
		'imagecenter',
		'link',
		'forecolor',
		'backcolor',
		'insertorderedlist',
		'insertunorderedlist',
		'imagecenter',
		'attachment',
		'autotypeset',
		'inserttable',
		'drafts',
		]
		],
		autoHeightEnabled: true,
		autoFloatEnabled: true
	};
	var ue = UE.getEditor('editor', editor);
	var ue1 = UE.getEditor('editor1', editor);
	$('.radio_status').click(function(){
		var show = $('input:radio[name="type"]:checked').val();
		$('input[name=points]').val(1);
		$('.vid').hide();
		$('.document').hide();
		if(show == 1){
			$('.vid').show();
		} else if(show == 2 || show == 4){
			;
			$('.document').show();
		} else if(show == 3){
			$('input[name=points]').val(5);
		}
	});
	$(document).on('click','.upload-btn',function(){
		editindex = layer.open({
			type:1,
			title:'上传视频',
			content:$(".wrap"),
			area:['725px','580px'],
			btn:['确定'],
			yes: function(index, layero){
				layer.close(index);
			}
		});

	});
	
	function copyUrl2(){
		document.getElementById("txtcopy").select();document.execCommand("Copy");layer.msg("已复制好，可贴粘。")
	};
	$('#nav').change(function(){
		var nav_id = $(this).val();
		$("#type option:gt(0)").remove();
		$("#s option:gt(0)").remove();
		if(nav_id == ''){
			return;
		}
		$.ajax({
			type:'GET',
			url :"{:url('course/getType')}",
			data:'nav_id='+nav_id,
			dataType:'json',
			success : function(data){
				$.each(data.type_data, function(k,v){
					$('#type').append('<option value="'+v.type_id+'">'+v.type_name+'</option>');
				});
			}
		});
	});
	$('#type').change(function(){
		var type_id = $(this).val();
		$("#s option:gt(0)").remove();
		if(type_id == ''){
			return;
		}
		$.ajax({
			type:'GET',
			url :"{:url('getS')}",
			data:'type_id='+type_id,
			dataType:'json',
			success : function(data){
				$.each(data.s_data, function(k,v){
					$('#s').append('<option value="'+v.s_id+'">'+v.s_name+'</option>');
				});
				$('input[name=course_sort]').val(data.sort);
			}
		});
	});
</script>
<script id="template-upload" type="text/x-tmpl">
	{% for (var i=0, file; file=o.files[i]; i++) { %}
	<tr class="template-upload">
		<td style="width:300px;">
			<p class="name" style="margin-top: 6px;">{%=file.name%}</p>
			<strong class="error text-danger"></strong>
		</td>
		<td>
			<p  style="margin-top: 6px;">{%=file.extendName%}</p>
		</td>
		<td>
			<p  style="margin-top: 6px;" title="{%=file.categoryDesc%}">{%=file.shortCategoryDesc%}</p>
		</td>
		<td style="width:80px;">
			<p class="size" style="margin-top: 6px;">处理中...</p>
		</td>
		<td class="progressbar">
			<div style="margin-top:6px;margin-bottom:4px;margin-left: 20px;width:150px;display:inline-block;" class="progress progress-striped active mb0 tc_rel" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
				<div class="progress-bar progress-bar-success" style="width:0%;"></div>
				<div style="margin-top: 1px;" class="tc tc_pos upload_percent progress-u">0%</div>
			</div>
			<span class="rate" style="vertical-align:super; margin-top:6px; margin-left: 20px;display:inline-block;"></span>
		</td>
		<td style="" class="operate">
			{% if (!i && !o.options.autoUpload) { %}
			<button class="btn btn-primary btn-xs start" style="margin-top:3px;" disabled>
				<i class="glyphicon glyphicon-upload"></i>
				<span>开始上传</span>
			</button>
			{% } %}
			{% if (!i) { %}
			<button class="btn btn-warning btn-xs cancel" style="margin-top:3px;">
				<i class="glyphicon glyphicon-ban-circle"></i>
				<span>取消</span>
			</button>
			{% } %}
			{% if (!i) { %}
			<button class="btn btn-primary btn-xs" id="pause" style="margin-top:3px;" disabled>
				<i class="glyphicon glyphicon-ban-circle"></i>
				<span>暂停</span>
			</button>
			{% } %}
			{% if (!i) { %}
			<button class="btn btn-primary btn-xs" id="resume" style="display:none; margin-top:3px;">
				<i class="glyphicon glyphicon-upload"></i>
				<span>续传</span>
			</button>
			{% } %}
		</td>
		<td width="0%" style="display:none">
			<input id="isPause" value="false">
		</td>
	</tr>
	{% } %}
</script>
<script src="__PUBLIC__admin/play/categoryLayer.js"></script>
<script src="__PUBLIC__admin/play/tmpl.min.js"></script>
<script src="__PUBLIC__admin/play/cch5upload.js"></script>
<script src="__PUBLIC__admin/play/index.js"></script>
